<ui:composition template="/admin/templates/ui2.xhtml"
	xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:composite="http://java.sun.com/jsf/composite/primefaces"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui"
	xmlns:fn="http://java.sun.com/jsp/jstl/functions"
	xmlns:c="http://java.sun.com/jsp/jstl/core"
	xmlns:sec="http://www.springframework.org/security/facelets/tags">


	<ui:define name="content">
		<div class="entry">
			<p:toolbar>
				<p:toolbarGroup>
					<h:outputLabel style="padding-left: 15px;"
						value="#{commonMsg.currentPositionLabel} #{menuMsg.menuTypeManageLabel}"></h:outputLabel>
				</p:toolbarGroup>
				<p:toolbarGroup align="right">
					<p:separator />
					<p:button value="#{menuMsg.addMenuTypeLabel}"
						outcome="/admin/menu/menuTypeEdit"></p:button>
				</p:toolbarGroup>
			</p:toolbar>
			<h:form id="form">
				<p:spacer></p:spacer>
				<p:panel id="filters">
					<h:inputText id="searchId" value="#{menuTypeList.example.id}"></h:inputText>
					<h:inputText id="searchName" value="#{menuTypeList.example.name}"></h:inputText>
					<p:commandButton process="filters" update="dataTable"
						value="#{commonMsg.searchLabel}"></p:commandButton>
				</p:panel>
				<p:watermark for="searchId" value="#{commonMsg.IDLabel}" />
				<p:watermark for="searchName" value="#{commonMsg.nameLabel}"></p:watermark>

				<p:spacer></p:spacer>
				<p:dataTable id="dataTable" value="#{menuTypeList.lazyModel}"
					var="menuType" paginator="true" paginatorPosition="bottom"
					rows="15" emptyMessage="#{commonMsg.noResultMsg}" lazy="true"
					currentPageReportTemplate="#{commonMsg.pageReportTemplate}"
					paginatorTemplate="#{commonMsg.paginatorTemplate}"
					rowsPerPageTemplate="15,50,100">
					<p:column headerText="#{commonMsg.IDLabel }" sortBy="menuType.id">
						<h:outputText value="#{menuType.id}"></h:outputText>
					</p:column>
					<p:column headerText="#{menuMsg.menuTypeLabel }"
						sortBy="menuType.name">
						<h:outputText value="#{menuType.name}"></h:outputText>
					</p:column>
					<p:column headerText="#{commonMsg.enableLabel}"
						sortBy="menuType.name">
						<h:outputText rendered="#{menuType.enable == '1'}"
							value="#{commonMsg.enableSelectLabel}"></h:outputText>
						<h:outputText rendered="#{menuType.enable == '0'}"
							value="#{commonMsg.disableSelectLabel}"></h:outputText>
					</p:column>
					<p:column headerText="#{commonMsg.descriptionLabel}">
						<h:outputText value="#{menuType.description}"></h:outputText>
					</p:column>
					<p:column headerText="#{commonMsg.actionLabel}">
						<sec:ifAllGranted roles="MENU_TYPE_EDIT">
							<h:link value="#{commonMsg.editLabel}"
								outcome="/admin/menu/menuTypeEdit?id=#{menuType.id}"></h:link> | 
                    <a href="javascript:void(0)"
								onclick="$('#form\\:deleteId').val('#{menuType.id}');confirmDialog.show()">#{commonMsg.deleteLabel}</a>|
                    </sec:ifAllGranted>
						<h:link value="#{menuMsg.menuListLink}"
							outcome="/admin/menu/menuList?typeId=#{menuType.id}"></h:link> | 
                    <sec:ifAllGranted roles="MENU_EDIT">
							<h:link value="#{menuMsg.addMenuLabel}"
								outcome="/admin/menu/menuEdit?typeId=#{menuType.id}"></h:link>
						</sec:ifAllGranted>
					</p:column>
					<f:facet name="footer"> 
						<p:commandButton value="导出Excel" ajax="false">
							<p:dataExporter target="dataTable" type="xls" 
								fileName="menuTypeList" pageOnly="false"></p:dataExporter>
						</p:commandButton>
	 		        </f:facet>
				</p:dataTable>
				<p:confirmDialog width="500" id="confirmDialog"
					widgetVar="confirmDialog" severity="alert"
					header="#{commonMsg.confirmDetele}"
					message="#{menuMsg.deleteMenuTypeInfo}">
					<h:inputHidden value="#{menuTypeHome.id}" id="deleteId"></h:inputHidden>
					<p:commandButton id="confirm" value="#{commonMsg.confirmLabel}"
						action="#{menuTypeHome.delete}" ajax="false"
						style="margin-left:180px;" />
					<p:commandButton id="decline" value="#{commonMsg.cancelLabel}"
						onclick="confirmDialog.hide()" type="button" />
				</p:confirmDialog>
			</h:form>
		</div>
	</ui:define>
</ui:composition>
